let name111: String = "我是一个好学生";
let ne111: number = 66;
ne = 23;
const hzk: String = "我是一个好学生";
let q: boolean = false;
q = true;
let l: number[] = [1, 2, 3];
let l1: Array<number> = [1, 2, 3];
let x: [String, number];

x = ['hello', 10];

enum Color { Red, Green, Blue }
let c: Color = Color.Green;

const hha: object = {
	"nl": 20, "name": "郝政凯", "sex": "男"
}

const dcm: object = {
	"ss": 23, "name": "大聪明", "sex": "男"
}

let add1: (x: number, y: number) => number =
	function (x: number, y: number): number {
		return x + y;
	};

function buildName(firstName: string, lastName = "Smith") {
	return firstName + " " + lastName;
}

let result1 = buildName("Bob");                  // works correctly now, returns "Bob Smith"
let result2 = buildName("Bob", undefined);       // still works, also returns "Bob Smith"
let result3 = buildName("Bob", "Adams", "Sr.");  // error, too many parameters
let result4 = buildName("Bob", "Adams");         // ah, just right

function add(x, y) {
	return x + y;
}

let z = 100;
function addTo2(x, y) {
	return x + y + z;
}

function add11(x: number, y: number): number {
	return x + y;
}

let myAdd = function (x: number, y: number): number {
	return x + y;
};

function h111(g: string | number, j: string | number) {
	if (typeof g === "string" && typeof j === "string") {
		return g + j;
	} else if (typeof g === "number" && typeof j === "number") {
		return g + j;
	} else {
		return g.toString() + j.toString();
	}
}

interface LaballedValue {
	label: string;
}


function printLabel(labelledObj: LaballedValue) {
	console.log(labelledObj.label);
}

let myObj = { size: 10, label: "Size 10 Object" };
printLabel(myObj);

interface SquareConfig {
	color?: string;
	width?: number;
}

function createSquare(config: SquareConfig): { color: string; area: number } {
	let newSquare = { color: "white", area: 100 };
	if (config.color) {
		newSquare.color = config.color;
	}
	if (config.width) {
		newSquare.area = config.width * config.width;
	}
	return newSquare;
}

let mySquare = createSquare({ color: "black" });




